package gson;

import com.google.gson.Gson;

import java.lang.reflect.Type;
import java.util.HashMap;

public class GsonTest1 {

    public static void main(String[] args) {

        GsonTest1Student student = new GsonTest1Student("1001", "lol", 21, "男", "一班");

        Gson gson = new Gson();
        String s = gson.toJson(student);
        System.out.println(s);

        String s2="{\"id\":\"1001\",\"name\":\"lol\",\"age\":21,\"sex\":\"男\",\"clazz\":\"一班\"}";


        GsonTest1Student json = gson.fromJson(s2, GsonTest1Student.class);
        System.out.println(json);

    }




}
